package com.kfm.commons;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;

@Data
public class AjaxResult {

//    @JsonFormat()
    private String msg;
    // 1 成功 0 失败
    private int code;

    private Object data;

    private AjaxResult() {
    }

    private AjaxResult(String msg, int code, Object data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }
    public static AjaxResult success() {
        return success(null);
    }

    public static AjaxResult success(Object data) {
        return success("success", data);
    }
    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult(msg, 1, data);
    }

    public static AjaxResult fail() {
        return new AjaxResult("fail", 0, null);
    }

    public static AjaxResult fail(String msg) {
        return  new AjaxResult(msg, 0, null);
    }



}
